﻿using StarryEdge.Core;
using StarryEdge.Core.Attributes;
using StarryEdge.Core.Device;
using StarryEdge.Core.Manager;
using StarryEdge.Core.Models;
using StarryEdge.Core.Parameter;
using StarryEdge.UserCore;
using StarryEdge.UserCore.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StarryEdge.Module.Handle.Handle
{
    [TaskClass("前扫码多")]
    public class MultiCodeBeforeScanCode<T> : HandleBase, IHandle<T>
    {
        IObjectManager _objectManager;
        public MultiCodeBeforeScanCode(IObjectManager objectManager, IStarryEdgeLog starryEdgeLog, IDialogHost dialogHost, ITemporaryParameter temporaryParameter, ISystemConfigParameter systemConfigParameter, IDeviceFactory deviceFactory) 
            : base(starryEdgeLog, dialogHost, temporaryParameter, systemConfigParameter, deviceFactory)
        {
            _objectManager = objectManager;
            _settingModel = new SettingModel();
            _testModel = new TestModel();
        }
        private SettingModel _settingModel;
        private TestModel _testModel;
        public Task<bool> Handle(HandleContext<T> context)
        {
            if (_objectManager.CopyObject<ISettingParameter, TestModel>(_testModel))
            {
                RunLog($"单例对象的值{_testModel.Count}", Core.Enums.LogLevel.Info, context);
            }
            else
            {
                RunLog("获取值失败", Core.Enums.LogLevel.Error, context);
            }
            //RunLog("更新成功", Core.Enums.LogLevel.Info, context);
            return Task.FromResult(true);
        }
    }
}
